package javaclass;

import java.util.ArrayList;

/*
* 题目：自定义四个学生对象，添加到集合，并且遍历、
*
*
* 思路：
* 1，自定义Student学生类，
* */
public class ArrayListStudent {
    public static void main(String[] args) {
        ArrayList<Student>  list =new ArrayList<>();

        Student one =new Student("小明",23);
        Student two =new Student("小花",21);
        Student three =new Student("小熊",20);
        Student four = new Student("小李",18);

        list.add(one);
        list.add(two);
        list.add(three);
        list.add(four);

        for (int i = 0; i < list.size(); i++) {
            Student stu =list.get(i);
            System.out.println(list.get(i).getName());
            System.out.println(list.get(i).getAge());
        }
    }
}
